import { MockMethod } from 'vite-plugin-mock'
const Mock = require('mockjs')
const { random } = require('lodash')
export default [
    {
        url: '/get/guest/list',
        method: 'get',
        timeout: 1000,
        response: (req) => {
            console.log(req.query)
            let productTypeList = ['南方', '科力达']
            let data = Mock.mock({
                code: 200,
                total: 1000,
                'record|10': [
                    {
                        date: '@date',
                        name: '@cname',
                        detail: '@cparagraph(3)',
                        putTel: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
                        productType: null,
                    },
                ]
            })
            data.record.forEach((item, idx, arr) => {
                arr[idx].productType = productTypeList[random(0, 1)]
            })
            return data
        },
    },
    {
        url: '/get/product_type/list',
        method: 'get',
        timeout: 100,
        response: (req) => {
            let data = Mock.mock({
                code: 200,
                list: [
                    {
                        label: '南方',
                        value: '南方'
                    },
                    {
                        label: '科力达',
                        value: '科力达'
                    },
                ]
            })
            return data
        },
    },
    {
        url: '/get/put_by/list',
        method: 'get',
        timeout: 100,
        response: (req) => {
            let data = Mock.mock({
                code: 200,
                list: [
                    { value: 'vue', link: 'https://github.com/vuejs/vue' },
                    { value: 'element', link: 'https://github.com/ElemeFE/element' },
                    { value: 'cooking', link: 'https://github.com/ElemeFE/cooking' },
                    { value: 'mint-ui', link: 'https://github.com/ElemeFE/mint-ui' },
                    { value: 'vuex', link: 'https://github.com/vuejs/vuex' },
                    { value: 'vue-router', link: 'https://github.com/vuejs/vue-router' },
                    { value: 'babel', link: 'https://github.com/babel/babel' },
                ]
            })
            return data
        },
    },
] as MockMethod[]